/*
 * Copyright (c) 2011-2012 Alexander Dubu
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * o  Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 * o  Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * o  Neither the name Axil nor the names of its contributors may be used to
 *    endorse or promote products derived from this software without specific
 *    prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package axil.api.access;

import java.lang.annotation.*;


/**
 * An annotation indicating a field that is accessible to an Axil script. This
 * annotation can be used on both Java fields (object data members) and methods
 * (accessor or "getter" methods). For example:
 * <pre>
 *     &#64;AccessibleType
 *     public class Shirt
 *     {
 *     		&#64;AccessibleField(name = "size", aliases = "shirt-size,sz")
 *        	private String size;
 *    	    private BigDecimal cost;
 *    	    private String code;
 *
 *    	    &#64;AccessibleField
 *    	    public BigDecimal getCost()
 *    	    {
 *    	        return cost;
 *    	    }
 *     }
 * </pre>
 * In this example, the "size" member is directly accessed. The "size" field
 * is accessible in an Axil script via the names "size", shirt-size" or "sz".
 * The "cost" field is accessed via the getCost() method. The field name "cost"
 * is inferred from the method name. Finally, the "code" field is not accessible
 * to an Axil script at all since the class was declared to allow only explicitly
 * specified fields to be accessible (the default).
 *
 * @see axil.api.Axil#identifiers(axil.api.Axil.Case, axil.api.Axil.Transformation)
 * @see axil.api.Axil#access(Class, FieldDefinition...)
 */
@Retention(RetentionPolicy.RUNTIME)
@Target( {ElementType.METHOD, ElementType.FIELD })
@Inherited
public @interface AccessibleField {
	/**
	 * An optional attribute for the annotation to provide an explicit name.
	 * If this attribute is not specified, then the compiler will infer the
	 * field name using the name of the field/method and the configuration
	 * identifier rules.
	 *
	 * @return
	 * 	Returns the name, or a blank indicating the name should be inferred.
	 *
	 * @see axil.api.Axil#identifiers(axil.api.Axil.Case, axil.api.Axil.Transformation)
	 */
String name() default "";

	/**
	 * An optional set of additional aliases by which the same field will be
	 * known. This feature enables backwards compatibility when a field can be
	 * known by an alternate form. The aliases are specified as a string of
	 * comma-separated values.
	 *
	 * @return
	 * 	Returns the aliases, if any.
	 */
String aliases() default "";
}
